//
//  MyDocumentPublishViewModel.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/5.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "MyDocumentPublishViewModel.h"

@implementation MyDocumentPublishViewModel

#pragma mark - Ovrride
- (void)initialize
{
    [super initialize];
    
    @weakify(self)
    
    self.uploadImgs = [NSMutableArray array];
    
    self.addImgCmd = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
        
        @strongify(self);
        
        NSMutableArray* newUploadImgs = [NSMutableArray arrayWithArray:[self.uploadImgs arrayByAddingObjectsFromArray:input]];
        
        self.uploadImgs = newUploadImgs;
        
        return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
            
            [subscriber sendNext:nil];
            [subscriber sendCompleted];
            
            return nil;
        }];
    }];
    
    self.deleteImgCmd = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
        
        @strongify(self);
        
        self.uploadImgs = [NSMutableArray arrayWithArray:self.uploadImgs];
        
        return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
            
            [subscriber sendNext:nil];
            [subscriber sendCompleted];
            
            return nil;
        }];
    }];
    
}

@end
